﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace shopNet
{
    class Category : EntityBase
    {
        public int cat_id{get;set;}
        public List<Category> sub{get;set;}
        public Category(shopnetEntities model, int id=0) { 
            _model = model;
            sub = new List<Category>();
            cat_id = id;
            var query = _model.categories.Where(it => it.parent == cat_id);
            var tmp = new List<int>();
            foreach (var item in query) {
                tmp.Add(item.categoryID);
            }
            foreach (var i in tmp) {
                sub.Add(new Category(_model,i));
            }

        }
    }
}
